import autoImport from 'unplugin-auto-import/vite'
import {ElementPlusResolver} from "unplugin-vue-components/resolvers";

export default function createAutoImport() {
    return autoImport({
        // 目标文件
        include: [
            /\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
            /\.vue$/, /\.vue\?vue/, // .vue
            /\.md$/, // .md
        ],
        // 全局引入插件
        imports: [
            'vue',
            'vue-router',
            'pinia',
            '@vueuse/core'
        ],
        dirs: ['src/store/modules/**', 'src/hooks/**', "src/utils/**"],
        resolvers: [ElementPlusResolver()],
        // eslint报错解决
        eslintrc: {
            enabled: false, // Default `false`
            filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
            globalsPropValue: true, // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
        },
        // 声明文件生成位置和文件名称
        dts: './auto-import.d.ts'
    })
}
